<template>
      <h2>登录</h2>
    <table class="table table-bordered"> 
        <tr>
            <td>账号</td>
            <td>
                <input type="text" v-model="info.name">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="text" v-model="info.pwd">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="登录" @click="login" >
            </td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'
import {useRouter} from 'vue-router'

const router=useRouter()

const info=ref({
    name:'',
    pwd:''
})

const login=()=>{
    if(info.value.name==''){
        alert("用户名不能为空")
        return;
    }
    if(info.value.pwd==''){
        alert("密码不能为空")
        return;
    }
   axios.get('https://localhost:7231/api/Login/Login',{
        params:{
            name:info.value.name,
            pwd:info.value.pwd
        }
   })
    .then(res=>{
        if(res.data>0){
            alert("登录成功")
            
        }
        else{
            alert("登录失败")
            return;
        }
    })
    .catch(err=>{
        console.log(err)
    })
}
</script>

<style scoped>

</style>